package designPattern.observer.asynchronous;

import java.util.List;
import java.util.Vector;

import designPattern.observer.asynchronous.event.ObserverEvent;
import designPattern.observer.asynchronous.observer.Observer;

public class Observable {

	private List<Invoker> observerList = new Vector<Invoker>();

    public void addObserver(Observer observer) {
    	synchronized (this) {
    		observerList.add(new Invoker(observer));
		}
    }

    public void notifyObservers(ObserverEvent event) {
        for (Invoker invoker : observerList) {
        	invoker.invoke(event);
        }
    }
}
